import { Component, OnInit } from '@angular/core';
import {ActivatedRoute, Router} from "@angular/router";
import {OperService} from "../oper.service";
import {OneDialogService} from "../../../../widgets/one-dialog/one-dialog.service";
import {TableUtil} from "../../../../util/table-util";
import {PageSubject} from "../../../../util/page-subject";
import {ResponseUtil} from "../../../../util/response-util";
import {MsgResult} from "../../../../models/msg-result";
import {MsgConstants} from "../../../../constants/constants";
import {Oper} from "../oper";

@Component({
  selector: 'app-oper-detail',
  templateUrl: './oper-detail.component.html',
  styleUrls: ['./oper-detail.component.css']
})
export class OperDetailComponent implements OnInit {

  operLog : Oper;
  constructor(
    private router: Router,
    private route: ActivatedRoute,
    private operService: OperService,
    private dialogService: OneDialogService,
    private tableUtil: TableUtil,
    private pageSubject: PageSubject,
    private responseUtil: ResponseUtil
  ) {
    this.initOperObj();
  }

  ngOnInit() {
   this.getOperLogDetail();
  }

  getOperLogDetail(){
    let id = this.route.snapshot.params['id'];
    this.operService.getOperLogById(id).subscribe(
      result =>this.responseUtil.success(result,this.processDetailResult),
      error => this.responseUtil.error(error)
    );
  }

  private processDetailResult =(result:MsgResult)=>{
    if(result && result.code == MsgConstants.MSG_CODE_OK){
      this.operLog = result.data;
    }
    if(result && result.code != MsgConstants.MSG_CODE_OK){

    }
  }

  initOperObj(){
    this.operLog = new Oper;
  }

}
